/* 
 * File:   Game.h
 * Author: noe
 *
 * Created on 5 octobre 2013, 19:35
 */

#ifndef GAME_H
#define	GAME_H

#include "State.h"
#include <iostream>
#include <chrono>
#include <unistd.h>
#include "native.h"
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "thread"
#include "input.h"
#include "NetworkManager.h"
#include <cstdlib>

class Game {
public:
	
	/**
	 * singleton
     * @param width
     * @param height
     * @return the Game
     */
	static Game* createGame(int width, int height);
	
	/**
	 * singleton
     * @return the Game
     */
	static Game* getGame();
	
	/**
	 * width of the application
     * @return 
     */
	int getWidth() const;
	
	/**
	 * 
     * @return height of the application
     */
	int getHeight() const;
	
	/**
	 * 
	 * @return the current State
	 */
	State* getCurrentState() const;
	
	/**
	 * sets the current State
     * @param state
     */
	void setCurrentState(State* state);
	
	/**
	 * starts the mainloop
     * @return false if something went wrong
     */
	bool start();
	
	/**
	 * stops the mainloop
     */
	void stop();
	
	/**
	 * 
     * @return whether the game is running
     */
	bool isRunning() const;
	
	/**
	 * 
     * @return the NetworkManager
     */
	NetworkManager* getNetworkManager();
	
	Game(const Game& orig);
    virtual ~Game();

    
private:
    
    Game(int width, int height);
    int width;
    int height;
    float frameRate;
    bool running;
    State* currentState;
	NetworkManager* nm;
    void mainloop();
};

#endif	/* GAME_H */

